/*
 * 
 */
package com.china08.yxyapi.entity.mg.moments;

import java.util.List;

import javax.persistence.Id;

import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import com.china08.yxyapi.entity.mg.MongoBaseEntityNoId;
import com.china08.yxyapi.repository.mg.moments.YxyMomentsPraiseRepository;
import com.china08.yxyapi.util.SpringContextUtil;

/**
 * 学校班级圈,每发送一条班级圈,存储一条记录,图片存储成list的结构
 * 
 * @author Richard.Wang
 */
@SuppressWarnings("serial")
@Document(collection = "yxy.tea.moments.moments")
public class YxyMoments extends MongoBaseEntityNoId {

	/** The id. */
	@Id
	private String id;

	/** The sender id. */
	@Field(value = "sender_id")
	private String senderId;// 发送者ID

	/** The sender nick. */
	@Field(value = "sender_nick")
	private String senderNick;// 发送者昵称

	/** The avatar. */
	@Field(value = "avatar")
	private String avatar;// 发送人头像

	/** The sender username. */
	@Field(value = "sender_username")
	private String senderUsername;// 发送者用户名

	/** The class id. */
	@Field(value = "class_id")
	private String classId;// 班级ID

	/** The class nick. */
	@Field(value = "class_nick")
	private String classNick;// 班级名称

	/** The school id. */
	@Field(value = "school_id")
	private String schoolId;// 学校ID

	/** The style intro. */
	@Field(value = "style_intro")
	private String styleIntro;// 班级圈内容

	/** The is share all. 1:默认公开 0:不公开 */
	@Field(value = "is_share_all")
	private int isShareAll = 1;// 是否公开

	/** The style imgs. */
	@Field(value = "style_imgs")
	@Deprecated
	private String styleImgs;// 暂时不使用

	/** The comment count. */
	@Field(value = "comment_count")
	private Integer commentCount;// 评论数量

	/** The imgs. */
	@Field(value = "imgs") // 照片
	private List<String> imgs;

	/**
	 * 状态 0:删除 1:有效
	 */
	@Field(value = "status")
	private Integer status = 1;

	/** prase 点赞数 */
	@Field(value = "praise_count")
	private Integer praiseCount;//

	// 其它功能所产生的班级圈信息,以下字段为新增
	@Field(value = "source")
	private Integer source;// 0-班级圈发布,1-班级通知,2-班级作业,3-家庭作业,4-课程分享

	@Field(value = "title")
	private String title;// 标题

	@Field(value = "cover_image")
	private String coverImage;// 封面

	@Field(value = "source_id")
	private String sourceId;// 来源所对应的id,例如班级通知id,班级昨天id

	@Field(value = "source_lesson_type")
	private String sourceLessonType;// 分享课程时,课程类型: 0-同步,1-专题,2-校本

	public Integer getPraiseCount() {
		return praiseCount;
	}

	public void setPraiseCount(Integer praiseCount) {
		this.praiseCount = praiseCount;
	}

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * Sets the id.
	 *
	 * @param id
	 *            the id
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * Gets the sender id.
	 *
	 * @return the sender id
	 */
	public String getSenderId() {
		return senderId;
	}

	/**
	 * Sets the sender id.
	 *
	 * @param senderId
	 *            the sender id
	 */
	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}

	/**
	 * Gets the sender nick.
	 *
	 * @return the sender nick
	 */
	public String getSenderNick() {
		return senderNick;
	}

	/**
	 * Sets the sender nick.
	 *
	 * @param senderNick
	 *            the sender nick
	 */
	public void setSenderNick(String senderNick) {
		this.senderNick = senderNick;
	}

	/**
	 * Gets the sender username.
	 *
	 * @return the sender username
	 */
	public String getSenderUsername() {
		return senderUsername;
	}

	/**
	 * Sets the sender username.
	 *
	 * @param senderUsername
	 *            the sender username
	 */
	public void setSenderUsername(String senderUsername) {
		this.senderUsername = senderUsername;
	}

	/**
	 * Gets the class id.
	 *
	 * @return the class id
	 */
	public String getClassId() {
		return classId;
	}

	/**
	 * Sets the class id.
	 *
	 * @param classId
	 *            the class id
	 */
	public void setClassId(String classId) {
		this.classId = classId;
	}

	/**
	 * Gets the class nick.
	 *
	 * @return the class nick
	 */
	public String getClassNick() {
		return classNick;
	}

	/**
	 * Sets the class nick.
	 *
	 * @param classNick
	 *            the class nick
	 */
	public void setClassNick(String classNick) {
		this.classNick = classNick;
	}

	/**
	 * Gets the school id.
	 *
	 * @return the school id
	 */
	public String getSchoolId() {
		return schoolId;
	}

	/**
	 * Sets the school id.
	 *
	 * @param schoolId
	 *            the school id
	 */
	public void setSchoolId(String schoolId) {
		this.schoolId = schoolId;
	}

	/**
	 * Gets the style intro.
	 *
	 * @return the style intro
	 */
	public String getStyleIntro() {
		return styleIntro;
	}

	/**
	 * Sets the style intro.
	 *
	 * @param styleIntro
	 *            the style intro
	 */
	public void setStyleIntro(String styleIntro) {
		this.styleIntro = styleIntro;
	}

	/**
	 * Gets the is share all.
	 *
	 * @return the checks if is share all
	 */
	public int getIsShareAll() {
		return isShareAll;
	}

	/**
	 * Sets the is share all.
	 *
	 * @param isShareAll
	 *            the checks if is share all
	 */
	public void setIsShareAll(int isShareAll) {
		this.isShareAll = isShareAll;
	}

	/**
	 * Gets the style imgs.
	 *
	 * @return the style imgs
	 */
	public String getStyleImgs() {
		return styleImgs;
	}

	/**
	 * Sets the style imgs.
	 *
	 * @param styleImgs
	 *            the style imgs
	 */
	public void setStyleImgs(String styleImgs) {
		this.styleImgs = styleImgs;
	}

	/**
	 * Gets the imgs.
	 *
	 * @return the imgs
	 */
	public List<String> getImgs() {
		return imgs;
	}

	/**
	 * Sets the imgs.
	 *
	 * @param imgs
	 *            the imgs
	 */
	public void setImgs(List<String> imgs) {
		this.imgs = imgs;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public Integer getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(Integer commentCount) {
		this.commentCount = commentCount;
	}

	/**
	 * 获取点赞人姓名拼接字符串，拼接字符为spilt
	 * 
	 * @param spilt
	 * @return
	 */
	public String getPraiseUserNickStr(String spilt) {
		YxyMomentsPraiseRepository yxyMomentsPraiseRepository = SpringContextUtil
				.getBean(YxyMomentsPraiseRepository.class);
		List<YxyMomentsPraise> yxyMomentsPraiseLst = yxyMomentsPraiseRepository
				.findByMomentsIdOrderByCreatedDateDesc(id);
		if (yxyMomentsPraiseLst == null || yxyMomentsPraiseLst.size() == 0) {//
			return "";
		}
		StringBuffer praiseUserNickStr = new StringBuffer();
		for (int i = 0; i < yxyMomentsPraiseLst.size(); i++) {
			praiseUserNickStr.append(yxyMomentsPraiseLst.get(i).getUserNick());
			if (i < yxyMomentsPraiseLst.size() - 1) {
				praiseUserNickStr.append(spilt);
			}
		}
		return praiseUserNickStr.toString();
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

}
